package com.tedu.API;

import org.junit.Test;

import java.util.Locale;

public class 作业 {
    //1.输出字符串"HelloJava"的字符串长度
    @Test
    public void testLength1(){
        String a="HelloJava";
        System.out.println(a.length());
    }
    //2.输出"HelloJava"中o的位置
    @Test
    public void testIndexOf2(){
        String b="HelloJava";
        int index =b.indexOf("o");
        System.out.println("o的位置是："+index);
    }
    //3.输出"HelloJava"中下标为5处开始第一次出现以"o"的位置
    @Test
    public void testIndexOf3(){
        String b="HelloJava";
        int index=b.indexOf("o");
        index =b.lastIndexOf("o");
        System.out.println("o出现的位置是：" + index);
    }
    //4.截取"HelloJava"中"Hello"并输出
    @Test
    public void testSubString4(){
        String c="HelloJava";
        c=c.substring(0,5);
        System.out.println("截取为："+c);
    }
    //5.截取"HelloJava"中"Java"并输出
    @Test
    public void testSubStrings5(){
        String c="HelloJava";
        c=c.substring(5,9);
        System.out.println("截取为："+c);
    }
    //6.将字符串" Hello "中两边的空白去掉后输出
    @Test
    public void testTrim6(){
        String a="     Hello ";
        a=a.trim().toLowerCase();
        System.out.println("去掉空格后为："+a);
    }
    //7.输出"HelloJava"中第6个字符"J"
    @Test
    public void testIndexOf7(){
        String b="HelloJava";
        int index = b.indexOf("j");
        index =b.indexOf(b="j",6);
        System.out.println("第六个为："+b);
    }
    //8.将"HelloJava"转换为小写，然后转换为大写
    @Test
    public void toLowerCase8(){
        String a="HelloJava";
        a=a.toLowerCase();
        System.out.println("转化为小写："+a);
        a=a.toUpperCase();
        System.out.println("转化为大写："+a);
    }
}
